Skip to content

Update to Swift 6.1 #3761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 17, 2025
Merged

Update to Swift 6.1 #3761

merged 22 commits into from
Apr 17, 2025

Conversation

finestructure
Copy link
Member

@finestructure finestructure commented Apr 11, 2025

This updates to the Swift 6.1 base image spi-base:1.2.0.

It also drops SwiftPM as a dependency in favour of a new package PackageCollections, in order to work around the issues #3755 and #3759.

This replacement package does not yet support package collections signing. This means we will not be signing the package collections we host until it does.

Fixes #3755 and #3759.

$(swift build --show-bin-path -c release)/Run serve --port 8080 --hostname 0.0.0.0 &
sleep 10
echo Probing api/version...
bash -c '[ "$(curl -sL -w "%{http_code}" -o /dev/null http://127.0.0.1:8080/api/version)" == "200" ] || (echo Connection failed ; exit 1)'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a new smoke test where we launch the release build and probe it via curl.

I've tested this with a debug build (which is not broken) here: https://github.com/SwiftPackageIndex/SwiftPackageIndex-Server/actions/runs/14441053515/job/40491081845?pr=3761

@finestructure
Copy link
Member Author

I'm thinking we should put the package collection sources we extract from SwiftPM into its own package. That'll make it easier to see what the diffs are and perhaps add back signing later without dealing with all of the server project.

Package.swift Outdated
@@ -95,7 +95,7 @@ let package = Package(
.product(name: "DependenciesTestSupport", package: "swift-dependencies"),
.product(name: "SnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "InlineSnapshotTesting", package: "swift-snapshot-testing"),
.product(name: "XCTVapor", package: "vapor"),
.product(name: "VaporTesting", package: "vapor"),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's yet another wrinkle. Dropping SwiftPM as a dependency highlighted that we were lagging behind on Vapor updates. Running the tests with the latest version raised many warnings of the kind:

􀟈 Test show_owner() started.
🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻🔻
XCTVapor function triggered in a swift-testing context.
This will result in test failures not being reported.
Use 'app.testable()' in XCTest tests, and 'app.testing()' in swift-testing ones.
Use `XCTVaporContext.$emitWarningIfCurrentTestInfoIsAvailable.withValue(false) { /* Execute your tests here */ }` to avoid this warning.
Location: /Users/sas/Projects/SPI/spi-server/Tests/AppTests/AuthorControllerTests.swift:86
🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺🔺
2025-04-16T12:49:42+0200 info codes.vapor.application : component=server request-id=A3EE65CD-E41D-4147-8965-48D604664B2F [Vapor] GET /owner
􁁛 Test show_owner() passed after 0.526 seconds.

Test updates were needed to address these.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a big changeset. I might defer this to a separate PR once I've fixed all tests and ensure they are passing in CI.

There's currently one test failing, search_unauthenticated.

􀟈 Test search_unauthenticated() started.
2025-04-16T13:07:55+0200 info codes.vapor.application : request-id=10018F96-8B59-4A39-8293-6CAA49A5EE60 [Vapor] GET /api/search
􀢄 Test search_unauthenticated() recorded an issue at ApiTests.swift:125:21: Expectation failed: (res.status → 404 Not Found) == (.unauthorized → 401 Unauthorized)
􀄵 // validation
􀢄 Test search_unauthenticated() failed after 0.023 seconds with 1 issue.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are passing, I'm moving this to a follow-up PR.

@finestructure finestructure force-pushed the swift-6.1 branch 2 times, most recently from dd0a59e to 71f8e53 Compare April 17, 2025 08:50
@finestructure finestructure force-pushed the swift-6.1 branch 2 times, most recently from 62a56be to 75679ea Compare April 17, 2025 09:21
@finestructure finestructure marked this pull request as ready for review April 17, 2025 09:28
@finestructure finestructure enabled auto-merge April 17, 2025 09:28
@finestructure finestructure merged commit 49a8d0d into main Apr 17, 2025
5 of 6 checks passed
@finestructure finestructure deleted the swift-6.1 branch April 17, 2025 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Server hangs when running with Swift 6.1 image
2 participants